package com.beidasoft.web.util;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author fuchao
 * @Description 线程池工具
 * @createTime 2023年01月13日 11:36:00
 */
public class ThreadPoolUtil {

    private static ThreadPoolExecutor executor;

    private ThreadPoolUtil() {

    }

    public static ThreadPoolExecutor getThreadPoolExecutor() {
        if (executor == null) {
            synchronized (ThreadPoolUtil.class){
                if (executor == null){
                    executor = new ThreadPoolExecutor(10, 10, 1000, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(4));
                }
            }
        }
        return executor;
    }

}
